import com.example.demo.core.*;
import com.example.demo.util.Command;
import com.example.demo.util.JsonBody;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    List<String> connectedClients = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        AppServer appServer = new AppServer();
        appServer.server();
        for (boolean flag = true; flag;) {
            System.out.print("waiting command: ");
            Scanner scanner = new Scanner(System.in);
            String command = scanner.next();
            switch(command) {
                case "list":
                    System.out.println(appServer.getAllClientUUID());
                    break;
                case "setVol":
                    System.out.print("waiting uuid: ");
                    appServer.sendCommand(scanner.next(), Command.SET_MASTER_VOLUME, new String[]{"10"});
                    break;
                case "getVol":
                    System.out.print("waiting uuid: ");
                    appServer.sendCommand(scanner.next(), Command.GET_INFO, null, new ICommandCallback() {
                        @Override
                        public void onMessage(JsonBody msg) {
                            System.out.println("volume:" + msg.get("client_master_volume"));
                        }

                        @Override
                        public void onDisConnect() {
                            System.out.println("client disconnect");
                        }
                    });
                    break;
                case "q":
                    flag = false;
                    break;
                default:
                    break;

            }
        }
    }
}
